package com.sl.proxy.server.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sl.proxy.server.controller.req.system.PortGroupListReq;
import com.sl.proxy.server.controller.res.system.PortGroupListRes;
import com.sl.proxy.server.dao.domain.entity.PortGroupDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Date;
import java.util.List;


@Mapper
public interface PortGroupMapper extends BaseMapper<PortGroupDO> {

    List<PortGroupListRes> selectPortGroupListResList(IPage<PortGroupListRes> page, PortGroupListReq res);


   default void updateEnableStatus(String id, Integer enable, Date now){
       LambdaUpdateWrapper<PortGroupDO> set = Wrappers.lambdaUpdate(PortGroupDO.class)
               .eq(PortGroupDO::getId, id)
               .set(PortGroupDO::getEnable, enable);
       set.set(PortGroupDO::getModifyTime, now);
       this.update(null, set
       );
   }
}
